void clear(){
  for(int n=1;n<=9;n++){
    digitalWrite(n,LOW);
  }
}

void setup() {
  for(int n=1;n<=9;n++){
    pinMode(n,OUTPUT);
  }
}

void loop() {
  for(int n=1;n<=9;n++){
    digitalWrite(n,HIGH);
    delay(1000);
  }
  clear();
  for(int n=1;n<=9;n++){
    switch(n){
      case 1:
      digitalWrite(3,HIGH);
      digitalWrite(7,HIGH);
      break;
      case 2:
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(8,HIGH);
      digitalWrite(9,HIGH);
      break;
      case 3:
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(8,HIGH);
      digitalWrite(7,HIGH);
      break;
      case 4:
      digitalWrite(3,HIGH);
      digitalWrite(5,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(7,HIGH);
      break;
      case 5:
      digitalWrite(5,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(7,HIGH);
      digitalWrite(8,HIGH);
      break;
      case 6:
      digitalWrite(9,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(5,HIGH);
      digitalWrite(7,HIGH);
      digitalWrite(8,HIGH);
      digitalWrite(6,HIGH);
      break;
      case 7:
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(7,HIGH);
      break;
      case 8:
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(5,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(7,HIGH);
      digitalWrite(8,HIGH);
      digitalWrite(9,HIGH);
      break;
      case 9:
      digitalWrite(3,HIGH);
      digitalWrite(4,HIGH);
      digitalWrite(5,HIGH);
      digitalWrite(6,HIGH);
      digitalWrite(7,HIGH);
      digitalWrite(8,HIGH);
      break;
    }
    delay(1000);
    clear();
  }
}
